package io.renren.modules.gaokaobaobei.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.modules.gaokaobaobei.dao.ZhaoShengDao;
import io.renren.modules.gaokaobaobei.entity.ZhaoShengEntity;
import io.renren.modules.gaokaobaobei.service.ZhaoShengService;
import io.renren.modules.sys.shiro.ShiroUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;


@Service("zhaoShengService")
public class ZhaoShengServiceImpl extends ServiceImpl<ZhaoShengDao, ZhaoShengEntity> implements  ZhaoShengService {

    @Override
    public PageUtils queryPage(Map<String, Object> params,String type,String Admissionstype,String name) {
        String username = "";
        if (name==null){
            username = ShiroUtils.getSessionAttribute("username")+"";

        }else{
            username = name;
        }
        Page< ZhaoShengEntity> page = this.selectPage(
                new Query< ZhaoShengEntity>(params).getPage(),
                new EntityWrapper< ZhaoShengEntity>()
                       .like(StringUtils.isNotBlank(username),"username", username)
                        .eq(StringUtils.isNotBlank(type),"type",type)
                        .eq(StringUtils.isNotBlank(Admissionstype),"Admissionstype",Admissionstype)

        );
        return new PageUtils(page);
    }

    @Override
    public PageUtils queryPageAdmissionstype(Map<String, Object> params, String Admissionstype, String type, String name) {
        String username = "";
        if (name==null){
            username = ShiroUtils.getSessionAttribute("username")+"";
        }else{
            username = name;
        }
        Page< ZhaoShengEntity> page = this.selectPage(
                new Query< ZhaoShengEntity>(params).getPage(),
                new EntityWrapper< ZhaoShengEntity>()
                        .like(StringUtils.isNotBlank(username),"username", username)
                        .eq(StringUtils.isNotBlank(type),"type",type)
                        .eq(StringUtils.isNotBlank(Admissionstype),"Admissionstype",Admissionstype)
        );
        return new PageUtils(page);
    }


    @Override
    public boolean updateBeiZhuByUserName(Map<String, String> map) {
        return baseMapper.updateBeiZhuByUserName(map);
    }

    @Override
    public PageUtils PerformanceAudit(Map<String, Object> params,String Admissionstype,String name,String type) {
        Page< ZhaoShengEntity> page = this.selectPage(
                new Query< ZhaoShengEntity>(params).getPage(),
                new EntityWrapper< ZhaoShengEntity>()
                        .like(StringUtils.isNotBlank(name),"username",name )
                        .eq(StringUtils.isNotBlank(type),"type",type)
                        .eq(StringUtils.isNotBlank(Admissionstype),"Admissionstype",Admissionstype)

        );

        return new PageUtils(page);
    }

    @Override
    public void updateAgency(Map<String, Object> map) {
        baseMapper.updateAgency(map);
    }

    @Override
    public ZhaoShengEntity findUserById(int id) {
        return baseMapper.findUserById(id);
    }

}
